package com.jianyun.jyzs.widget;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.jianyun.jyzs.R;


/**
 * Created by liml on 17/6/27.
 */

public class RedPiontTextView extends LinearLayout{


    private TextView textview;
    private TextView point;

    public RedPiontTextView(Context context) {
        super(context);
        initView(null);
    }

    public RedPiontTextView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        initView(attrs);
    }
    @SuppressLint("WrongConstant")
    private void initView(AttributeSet attrs) {
        setOrientation(HORIZONTAL);
        inflate(getContext(), R.layout.view_point_text,this);
        textview = (TextView) findViewById(R.id.text);
        point = (TextView) findViewById(R.id.point);
        if (attrs!=null){
            TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.PointTextView);
            boolean aBoolean = typedArray.getBoolean(R.styleable.PointTextView_point, false);
            CharSequence text = typedArray.getText(R.styleable.PointTextView_point_text);
            textview.setText(text);
            textview.setTextSize(TypedValue.COMPLEX_UNIT_SP,18);
            if (aBoolean) point.setVisibility(VISIBLE);
            typedArray.recycle();
        }
    }

    public void setPointText(String text){
        textview.setText(text);
    }
    public void setPointVisbility(boolean b){
        if (b)point.setVisibility(VISIBLE);
        if (!b)point.setVisibility(INVISIBLE);
    }
    public void setTextColor(int color){
        textview.setTextColor(color);
    }
}
